﻿$(document).ready(function(){
	getTNavigations();//导航栏
});

/**
 * 获取头部导航栏
 * @return
 * 林銮
 * 2011-04-08
 */
function getTNavigations(){
	$("#ul_TNavigation").html('');

	$.post(common.getContextPath('/getTNavigations.do'), {
		
	}, function(data){
		var ob = eval('('+data+')');
		if(ob.success=="success"){			
			
			var html="";
			for(var i=0; i<ob.result.length;i++){
				var item = ob.result[i];
				if(i>19)continue
				var url=item.ITMENURL;
				if(url==null||url==""||url==undefined||url=="null")
				{
					url="#";
				}else{
					url=common.getContextPath(url);
				}
				switch (i) {
				case 9:
					html+='<li class="nbg"><a href="'+url+'">'+item.ITMEN+'</a></li>';
					break;
				case 19:
					html+='<li class="nbg"><a href="'+url+'">'+item.ITMEN+'</a></li>';
					break;
				default:
					html+='<li><a href="'+url+'">'+item.ITMEN+'</a></li>'; 
					break;
				}	
			}
			html+=' <li class="search"><span id="showTimeDiv"></span>&nbsp;&nbsp;&nbsp;&nbsp;站内搜索：<input name="sousuo" id="sousuo" type="text" />&nbsp;<input name="btn" type="button" value="搜索" onclick="golist()" /></li>';
			
			$("#ul_TNavigation").append(html); 
			showTime();
			 setInterval("showTime()",1000);
		}			
		
		}, 'html'
	);
}
function showTime(){
      var nowTime = new Date();
      var nowYear = nowTime.getFullYear();
      var nowMonth = nowTime.getMonth()+1;
      var nowDay = nowTime.getDate();
      var nowHours = nowTime.getHours();
      var nowMinutes = nowTime.getMinutes();
      var nowSeconds = nowTime.getSeconds();
      var nowWeek = nowTime.getDay();
      var weekSigne="";
      switch(nowWeek){
         case 0:
            weekSigne="星期日";
            break;
         case 1:
            weekSigne="星期一";
            break;
         case 2:
            weekSigne="星期二";
            break;
         case 3:
            weekSigne="星期三";
            break;      
         case 4:
            weekSigne="星期四";
            break;
         case 5:
            weekSigne="星期五";
            break;      
         case 6:
            weekSigne="星期六";
            break;   
      }
      var signe="上午";
      if(nowHours>12){
         nowHours= nowHours-12;
         signe="下午";
      }
      if(nowHours<10){
         nowHours="0"+nowHours;
      }
      if(nowMinutes<10){
         nowMinutes="0"+nowMinutes;
      }
      if(nowSeconds<10){
         nowSeconds="0"+nowSeconds;
      }
      $('#showTimeDiv').html('今天是： '+nowYear+'年'+nowMonth+'月'+nowDay+'日   '+weekSigne+'  '+signe+' '+nowHours+':'+nowMinutes+':'+nowSeconds);
      //document.getElementById('viewTime').innerHTML="<FONT COLOR='RED' SIZE='-1'>"+nowYear+"年&nbsp;"+nowMonth+"月&nbsp;"+nowDay+"日&nbsp;&nbsp;"+signe+"&nbsp;&nbsp;"+nowHours+" ："+nowMinutes+" ："+nowSeconds+"&nbsp;"+weekSigne+"</font>";
 }


function getTiciList(id,page){//领导题词
	 $("#dataTiciList").html('');
	var html="";
	 html+='<h1><span><a href="list.html?id=10000044">更多>></a></span><a href="list.html?id=10000044">领导题词</a></h1>';
	 html+='<ul id="datatclist">';
	 html+='</ul>';
	 $("#dataTiciList").html(html);
	$.post(common.getContextPath('/getArcitleTop.do'), {
		PartID:id,
		pageNo: 1,
		pageSize: page
	}, function(data){
		var ob = eval('('+data+')'); 
			var html="";
			for(var i=0; i<ob.result.length;i++){
				var item = ob.result[i];
				 html='<li><span>'+common.substring(item.publisheddate, 9)+'</span><a href="list07.html?id='+item.id+'">'+common.substring(item.title, 10)+'</a></li>';
				$("#datatclist").append(html);
			}
			if(ob.result.length==0){$("#datatclist").html('<li>暂无内容</li>')}
			}, 'html'
		);
}


function getYueKanList(id,page){//月刊
	var html="";
	 html+='<h1><span><a href="list03.html">更多>></a></span><a href="list03.html">月刊扫描</a></h1>';
	 html+=' <ul id="dataYKList">';
	 html+=' </ul>';
	 $("#dataYueKanList").html(html);
	$.post(common.getContextPath('/getArcitleByPartId.do'), {
		PartID:id,
		pageNo: 1,
		pageSize: page
	}, function(data){
		var ob = eval('('+data+')'); 
			for(var i=0; i<ob.result.length;i++){
				var item = ob.result[i];
				 html='<li class="pc"><img src="'+findImgUrl(item.content)+'" width="188" height="287" /><h2><a href="list05.html?id='+item.id+'">'+item.title+'</a></h2></li>';
				$("#dataYKList").append(html);
			}
			if(ob.result.length==0){$("#dataYKList").html('<li>暂无内容</li>')}
			}, 'html'
		);
}

function getZxList(id,page){//最新动态
	var html="";
	 html+='<h1><span><a href="list.html?id=10000045">更多>></a></span><a href="list.html?id=10000045">最新动态</a></h1>';
	 html+='<ul id="dataZuixinList"></ul>';
	 $("#dataZxList").html(html);
	$.post(common.getContextPath('/getArcitleTop.do'), {
		PartID:id,
		pageNo: 1,
		pageSize: page
	}, function(data){
		var ob = eval('('+data+')'); 
			var html="";
			for(var i=0; i<ob.result.length;i++){
				var item = ob.result[i];
				var html="";
				var url='list07.html';
				if(item.partid=="10000048"){
					url='list05.html';
				}
				 html='<li><span>'+common.substring(item.publisheddate, 9)+'</span><a href="'+url+'?id='+item.id+'">'+common.substring(item.title, 10)+'</a></li>';
				$("#dataZuixinList").append(html);
			}
			if(ob.result.length==0){$("#dataZuixinList").html('<li>暂无内容</li>')}
			}, 'html'
		);
}
//获得第一张图片路径
function findImgUrl(img){
	var url="";	
	var re=/<img(?= )[^>]* src=(['"])(.*?)\1[^>]*>/i;  //正则表达式
		if(re.test(img)){
			url=img.match(re)[2];			               
		}
	return url;
}

function golist(){
	window.location = common.getContextPath('/list.html?title='+$('#sousuo').val());
}
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
	var image=new Image();
		image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= iwidth/iheight){
			if(image.width>iwidth){
				ImgD.width=iwidth;
				ImgD.height=(image.height*iwidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.alt=image.width+"×"+image.height;
		}
		else{
			if(image.height>iheight){
				ImgD.height=iheight;
				ImgD.width=(image.width*iheight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
				ImgD.alt=image.width+"×"+image.height;
		}
	}
} 